package com.ds.lens.data.common.client;

import com.ds.lens.data.common.client.vo.*;
import com.ds.lens.data.common.document.ForecastData;
import com.ds.lens.data.common.document.datasource.LensDatasource;
import com.ds.lens.data.common.document.MetricState;
import feign.Headers;
import feign.Param;
import feign.RequestLine;

import java.util.List;
import java.util.Map;

public interface LensMonitorClient {

    @RequestLine("GET /lens/inner/application/get?appKey={appKey}")
    LensResponseData<LensApplicationOutVO> getApplicationByKey(@Param("appKey") String appKey);

    @RequestLine("GET /lens/inner/application/list")
    LensResponseData<List<LensApplicationNameOutVO>> listAllApplications();

    @RequestLine("GET /lens/inner/application/listUpdated?lastModifyTime={lastModifyTime}")
    LensResponseData<List<LensApplicationNameOutVO>> listUpdatedApplications(@Param("lastModifyTime") Long lastModifyTime);

    @RequestLine("GET /lens/inner/monitor/listAvailableMonitorState")
    LensResponseData<List<MonitorKeyOutVO>> listAvailableMonitorState();

    @RequestLine("GET /lens/inner/monitor/listUpdatedMonitorState?lastModifyTime={lastModifyTime}")
    LensResponseData<List<MonitorKeyOutVO>> listUpdatedMonitorState(@Param("lastModifyTime") Long lastModifyTime);

    @RequestLine("GET /lens/inner/monitor/get?id={id}")
    LensResponseData<LensMonitorDetailsOutVO> getMonitorDefinition(@Param("id") Long id);

    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @RequestLine("POST /lens/inner/monitor/tags")
    LensResponseData<List<LensMonitorDetailsOutVO>> getMonitorDetailsByTags(LensMonitorTagsSearchVO tagsSearchVO);


    @RequestLine("GET /lens/inner/monitor/state/get?monitorId={monitorId}&version={version}&target={target}")
    LensResponseData<LensMonitorStateOutVO> getLatestMonitorEventState(@Param("monitorId") Long monitorId,
                                                                       @Param("version") Integer version,
                                                                       @Param("target") String target);

    @RequestLine("GET /lens/inner/monitor/updateState?id={monitorId}&state={state}")
    LensResponseData<Object> updateMonitorState(@Param("monitorId") Long monitorId, @Param("state") Integer state);

    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @RequestLine("POST /lens/inner/monitor/state/save")
    LensResponseData<Map<String, MetricState>> saveMonitorState(LensMonitorStateSaveInVO monitorEventState);

    @RequestLine("GET /lens/metricstags/getAllMetricsTags")
    LensResponseData<List<LensMetricsTags>> getAllMetricsTags();

    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @RequestLine("POST /lens/metricstags/save")
    LensResponseData<Object> saveMetricsTags(List<LensMetricsTagsInVO> metricsTagsInVOList);

    @RequestLine("GET /lens/inner/integration/get?id={id}")
    LensResponseData<LensIntegrationOutVO> getIntegrationInfo(@Param("id") Long id);

    @RequestLine("GET /lens/inner/monitor/channel/get?monitorId={monitorId}&version={version}&target={target}&type={type}")
    LensResponseData<LensMonitorChannel> getMonitorChannel(@Param("monitorId") Long monitorId, @Param("version") Integer version,
                                                           @Param("target") String target, @Param("type") Integer type);

    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @RequestLine("POST /lens/inner/monitor/channel/save")
    LensResponseData<Boolean> saveMonitorChannel(LensMonitorChannelInVO channelInVO);

    @RequestLine("GET /lens/inner/metric/query/{monitorId}/{startTime}/{endTime}/{interval}")
    LensResponseData<List<Map<String, Object>>> queryMetrics(@Param("monitorId") Long monitorId,
                                                             @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("interval") Long interval);

    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @RequestLine("POST /lens/inner/metric/enhanceQuery")
    LensResponseData<List<Map<String, Object>>> queryMetrics(LensMetricInVO metricInVO);

    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @RequestLine("POST /lens/inner/external/event/start")
    LensResponseData<Boolean> startExternalEvent(LensExternalEventInVO inVO);

    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @RequestLine("POST /lens/inner/external/event/complete")
    LensResponseData<Boolean> completeExternalEvent(LensExternalEventInVO inVO);

    @RequestLine("GET /lens/inner/forecast/metric/query/{monitorId}/{version}/{startTime}/{endTime}")
    LensResponseData<List<ForecastData>> queryForecastMetrics(@Param("monitorId") Long monitorId, @Param("version") Integer version,
                                                              @Param("startTime") Long startTime, @Param("endTime") Long endTime);

    @RequestLine("GET /lens/inner/datasource/get?id={id}")
    LensResponseData<LensDatasource> queryDatasource(@Param("id") Long id);
}
